<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class SetupBasketsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //

        // Creates the users table
        Schema::create('baskets', function ($table) {
            $table->increments('id');
            $table->integer('member_id')->unsigned()->default(0)->comment('会员ID');
            $table->integer('food_id')->unsigned()->default(0)->comment('食物ID');
            $table->integer('count')->unsigned()->default(0)->comment('数量');
            $table->timestamps();
            $table->foreign('member_id')->references('id')->on('members');
            $table->foreign('food_id')->references('id')->on('foods');

            $table->index('member_id');
            $table->index('food_id');
            $table->index('count');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::table('baskets', function(Blueprint $table) {
            $table->dropForeign('baskets_member_id_foreign');
            $table->dropForeign('baskets_food_id_foreign');
        });
        Schema::drop('baskets');
    }

}
